Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rename the list of variables with the name of each sheet*

    Hi, I am importing 3 sheets from excel and I want to rename the list of variables with the name of each sheet

    In my do I have:
    cd "D:\Do\Mat"
    local hojas "RB RM RA"
    foreach i of local hojas {
    import excel "\BDMattt2019.xlsx", sheet("`i'") firstrow clear
    ...
    ....
    ....
    save "P_`i'.dta",replace


    My vars are 20 : from INI_CDT_INT_EIB_0200_F_4 to INI_CDT_INT_EIB_4700_F_5

    Using one var it would be :

    rename INI_CDT_INT_EIB_0200_F_4 INI_CDT_INT_EIB_0200_F_4_R_`i',

    but I want to reply this in all vars(20) for each sheet.

    I want this results in my first database ( P_RB):

    Id INI_CDT_INT_EIB_0200_F_4_R_RB INI_CDT_INT_EIB_4700_F_5_R_RB
    1
    2
    3
    4
    .
    .
    .
    In my second database ( P_RM):
    Id INI_CDT_INT_EIB_0200_F_4_R_RM INI_CDT_INT_EIB_4700_F_5_R_RM
    1
    2
    3
    4
    .
    .
    .

    In my second database ( P_RA):
    Id INI_CDT_INT_EIB_0200_F_4_R_RA INI_CDT_INT_EIB_4700_F_5_R_RA
    1
    2
    3
    4
    .
    .
    .


    Kind Regards,

    Sumiko.
    0
    a
    0%
    0
    b
    0%
    0
Working...
X